package com.tengju.data.domain.model.report.performance;

import lombok.AllArgsConstructor;
import lombok.Getter;
import org.apache.commons.lang3.StringUtils;

@Getter
@AllArgsConstructor
public enum PerFormanceOrderType {

    //销售额 降序
    ORDER_SALES_REACHED_DESC("gmvRate","desc","降序"),
    //销售额 升序
    ORDER_SALES_REACHED_ASC("gmvRate","asc","升序"),
    //黑钻新增 降序
    ORDER_SVIP_REACHED_DESC("level4CntRate","desc","降序"),
    //黑钻新增 升序
    ORDER_SVIP_REACHED_ASC("level4CntRate","asc","升序"),
    //白金新增 降序
    ORDER_VVIP_REACHED_DESC("level3CntRate","desc","降序"),
    //白金新增 升序
    ORDER_VVIP_REACHED_ASC("level3CntRate","asc","升序"),
    //粉卡新增 降序
    ORDER_VIP_REACHED_DESC("level2CntRate","desc","降序"),
    //粉卡新增 升序
    ORDER_VIP_REACHED_ASC("level2CntRate","asc","升序"),
    //月入3000+ 降序
    ORDER_PROFIT_THREE_DESC("profit3000CntRate","desc","降序"),
    //月入3000+ 升序
    ORDER_PROFIT_THREE_ASC("profit3000CntRate","asc","升序");

    /**
     * 排序字段
     */
    private String orderColumn;
    /**
     * 排序规则
     */
    private String orderType;
    /**
     * 描述
     */
    private String desc;

    public static PerFormanceOrderType fromSortType(String orderColumn, String orderType) {
        //默认降序
        if (StringUtils.isEmpty(orderType) || StringUtils.isEmpty(orderColumn)) {
            return PerFormanceOrderType.ORDER_SALES_REACHED_DESC;
        }

        for (PerFormanceOrderType type : PerFormanceOrderType.values()) {
            if (type.orderType.equals(orderType) && type.orderColumn.equals(orderColumn)) {
                return type;
            }
        }
        return PerFormanceOrderType.ORDER_SALES_REACHED_DESC;
    }
}
